package edu.whu.demo.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.whu.demo.domain.Supplier;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

// 定义一个名为SupplierDao的接口，继承自BaseMapper<Supplier>
@Mapper
public interface SupplierDao extends BaseMapper<Supplier> {

    // 定义一个名为findSuppliersByProduct的方法，接收一个名为productId的参数，返回值类型为List<Supplier>
    // 该方法用于根据产品ID查询供应商信息
    @Select("select supplier.* from supplier, product_supplier " +
            "where supplier.id = product_supplier.supplier_id " +
            "and product_supplier.product_id = #{productId}")
    public List<Supplier> findSuppliersByProduct(@Param("productId")Long productId);

}